<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>

<title></title>
</head>
<body>
<div class="ibox-content">
	<form class="form-horizontal" id="dataform">

		<input type="hidden" name="tokenUrl" value="${tokenUrl}"> 
		<input type="hidden" name="token" value="${token}">

		<c:if test="${obj ne null }">
			<input type="hidden" name="loanId" value='<c:out value="${obj.loanId}"></c:out>'>
		</c:if>
		
		<div class="form-group">
			<label class="col-sm-2 control-label">班级<span class="red">*</span></label>
			<div class="col-sm-4">
				<select name="stuClass" id="stuClass" class="form-control autoFull select2"
					data-url="${path}/admin/tabClass/showAllClass"
					data-def="${obj.stuClass }" onchange="changeStudent()"	
					data-filed="claName" data-value="claId"
					datatype="*" nullmsg="班级不能为空">
					<option value="">--请选择所在班级--</option>
				</select>
				<div class="Validform_checktip"></div>
			</div>
			
			<label class="col-sm-2 control-label">学生<span class="red">*</span></label>
			<div class="col-sm-4">
				<select name="sId" id="stu" class="form-control autoFull select2 autoFull2"
					data-url="${path}/admin/studentinfo/showAllStudent"
					data-def="${obj.sId }" 
					data-filed="stuName" data-value="stuId"
					datatype="*" nullmsg="学生不能为空">
					<option value="">--请选择学生--</option>
				</select>
				<div class="Validform_checktip"></div>
			</div>
		</div>
		
	    <div class="form-group">			
			<label class="col-sm-2 control-label">银行卡号<span class="red">*</span></label>
			<div class="col-sm-4">
				<input type="text"  class="form-control" datatype="n1-30" maxlength="21"
					value='<c:out value="${obj.loanCard}"></c:out>' 
					name="loanCard" nullmsg="卡号不能为空" errormsg="请填写正确卡号">
				<div class="Validform_checktip"></div>					
			</div>
			
			 <label class="col-sm-2 control-label">规定还款日期<span class="red">*</span></label>
			<div class="col-sm-4">
				<input type="text"  class="form-control"
					value="${obj.loanRdate}" name="loanRdate" placeholder="请填写‘15号’或‘30号’"
					datatype="*" nullmsg="规定还款日期不能为空">
			</div>
		</div>
        
        <div class="form-group">
             <label class="col-sm-2 control-label">还款总金额<span class="red">*</span></label>
			<div class="col-sm-4">
				<input type="text" name="loanRamoney" value="${obj.loanRamoney}"
					class="form-control radius" 
					datatype="price" nullmsg="总金额不能为空" maxlength="9">
				<div class="Validform_checktip"></div>
			</div>
			
			<!-- <label class="col-sm-2 control-label">是否已还清<span class="red">*</span></label>
			<div class="col-sm-4">
				<input type="radio" name="loanIsnot" value="是"
					datatype="*" nullmsg="不能为空" >是
					<input type="radio" name="loanIsnot" value="否"
					datatype="*" nullmsg="不能为空" >否
				<div class="Validform_checktip"></div>
			</div> -->
			
			 <label class="col-sm-2 control-label">领款日期<span class="red">*</span></label>
			<div class="col-sm-4">
				<input type="text"  class="form-control  datetimepicker"  maxlength="10" name="loanDdate"
					value='<fmt:formatDate value="${obj.loanDdate }" pattern='yyyy-MM-dd' />'
					datatype="*" nullmsg="领款日期不能为空">
				<div class="Validform_checktip"></div>					
			</div> 
        </div>
        
        <div class="form-group">
			 <label class="col-sm-2 control-label">领款金额<span class="red">*</span></label>
			<div class="col-sm-4">
				<input type="text" name="loanDmoney" value="${obj.loanDmoney}"
					class="form-control radius" 
					datatype="price" nullmsg="领款金额不能为空" maxlength="8">
				<div class="Validform_checktip"></div>
			</div>
			
			<label class="col-sm-2 control-label">领款人<span class="red">*</span></label>
			<div class="col-sm-4">
				<input type="text" name="loanPayee" value="${obj.loanPayee}"
					class="form-control radius"  
					datatype="*" nullmsg="领款人不能为空" >
				<div class="Validform_checktip"></div>
			</div>
        </div>
        
		<div class="form-group">	
			<label class="col-sm-2 control-label">备注</label>
			<div class="col-sm-4">
				<textarea rows="6" cols="" class="form-control" name="loanRemarks"  
				datatype="*0-20">${obj.loanRemarks }</textarea>			
			</div>
		</div>
		
		<div class="form-group ">
			<div class="col-sm-12 text-center">
				<a href="javascript:;" onclick="myForm.submit()" class="btn btn-success radius">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;
				<button onclick="MTools.closeForm()" class="btn btn-danger radius" type="button">取消</button>
			</div>
		</div>
	</form>
</div>
</body>
<script type="text/javascript">
	var myForm;
	$(function(){
		//带搜索的下拉框
		$(".select2").select2({'width':'100%'});
		$(".select2").trigger("blur");
		//初始化下拉框
		MTools.autoFullSelect();
		//初始化日期控件
		MTools.ininDatetimepicker({
			listenBlur : true
		});
		//表格提交
		myForm = MForm.initForm({
			invokeUrl : "${path}/admin/loanReturn/addOrModify",
			afterSubmit : function() {
				parent.myGrid.serchData();
			},
		});
		
	<c:if test="${obj.stuClass ne null }">
		changeStudent()
	</c:if>
		
	});

	function changeStudent() {
		var stuClass = $("#stuClass").val();
		if (stuClass != '') {
			$("#stu").removeData("url");
			$("#stu").data("url", "${path}/admin/loanReturn/queryStuByClass?stuClass=" + stuClass);
			$("#stu").data("filed", "stuName");
			$("#stu").data("value", "stuId");
			<c:if test="${obj ne null }">
				$("#stu").data("def", "${obj.sId }");
			</c:if>
			$("#stu").empty();
			$("#stu").append('<option value="">-- 请选择指派人--</option>');
			MTools.autoFullSelect({
				selecteder : ".autoFull2"
			});
			$(".select2").select2({
				'width' : '100%'
			})
		} 
	}
	
	$('.select2').change(function() {
		if(this.value != "") {
			$(this).parent().children('.Validform_checktip').text('');
			$(this).parent().children('.Validform_checktip').removeClass('Validform_wrong');
			$(this).parent().children('.Validform_checktip').addClass('Validform_right');
		}
	})
</script>
</body>
</html>